package testBounce;

import static org.junit.Assert.*;
import YAPserver.behaviours.BounceMirror;
import YAPserver.gameObjects.GameBall;
import YAPserver.gameObjects.Point;
import YAPserver.gameObjects.GameWall;

import org.junit.*;

/**
 * This class is deprecated as the bouncemirror algorithm has been changed
 * not to reflect 100% mathematically.
 * Instead it moves the ball a bit more inward
 */
@Deprecated
public class TestBounceMirror {
	BounceMirror bounce;
	GameWall wall1;
	GameWall wall2;
	GameBall ball = new GameBall(new Point(300, 300), 0, 3, 5);
	
	@Before
	public void setup(){
		bounce = new BounceMirror();
		wall1 = new GameWall(new Point(0, 0), new Point(10, 10));
		wall2 = new GameWall(new Point(10, 10), new Point(0, 0));
		ball.setMiddlePoint(new Point(5, 0));
		ball.setAngle(Math.PI/2.);
	}
	
	@Test
	public void testReflectionWall1(){
		System.out.println(ball);
		bounce.bounce(ball, wall1);
		System.out.println(ball);
		assertTrue(ball.toString().equals("0"+"\t"+"5"+"\t"+"5"));
	}
	
	@Test
	public void testReflectionWall2(){
		ball.setMiddlePoint(new Point(5, 0));
		bounce.bounce(ball, wall2);
		assertTrue(ball.toString().equals("0"+"\t"+"5"+"\t"+"5"));
		bounce.bounce(ball, wall2);
	}
	
	@Test
	public void test90degree(){
		GameBall ball = new GameBall(new Point(-1, 5), 0, 1, 5);
		GameWall wall = new GameWall(new Point(0, 0), new Point(0, 10));
		bounce.bounce(ball, wall);
		assertTrue(ball.hasCollided(wall));
		
		String ballString = ball.toString();
		String expected = "1	5	5";
		assertTrue(ballString.equals(expected));
		
		ball.setMiddlePoint(new Point(-1.000000000000000000000001, 5));
		assertFalse(ball.hasCollided(wall));
		
		ball.setMiddlePoint(new Point(-1.00000000000000000000000000000000000000000000000000000000001, 5));
		assertFalse(ball.hasCollided(wall));
	}
}
